summaryrefslogtreecommitdiff
path: root/src/app/api/product/[id]/toggle-different
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-12-01 10:16:12 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-12-01 10:16:12 +0700
commitae3207e9778c3f2fb01d64714ff15fc073ec093d (patch)
tree7b4c8cd8c00fec4d9eeafec8e01e938917cbee2e /src/app/api/product/[id]/toggle-different
parent812e4ac0afc56ee3121a5673af35bf8be2f4432c (diff)
Update compute different, result, and product list feature
Diffstat (limited to 'src/app/api/product/[id]/toggle-different')
-rw-r--r--src/app/api/product/[id]/toggle-different/route.tsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/app/api/product/[id]/toggle-different/route.tsx b/src/app/api/product/[id]/toggle-different/route.tsx
new file mode 100644
index 0000000..987dbf3
--- /dev/null
+++ b/src/app/api/product/[id]/toggle-different/route.tsx
@@ -0,0 +1,16 @@
+import { NextRequest, NextResponse } from "next/server";
+import { prisma } from "prisma/client";
+
+type Params = { params: { id: string } }
+export async function POST(request: NextRequest, { params }: Params) {
+ const intId = parseInt(params.id)
+ const product = await prisma.product.findUnique({ where: { id: intId } })
+ const updatedProduct = await prisma.product.update({
+ where: { id: intId },
+ data: {
+ isDifferent: !product?.isDifferent
+ }
+ })
+
+ return NextResponse.json(updatedProduct)
+} \ No newline at end of file